package top.kangyaocoding.tech.config;

import org.springframework.ai.chat.client.ChatClient;
import org.springframework.ai.chat.client.advisor.MessageChatMemoryAdvisor;
import org.springframework.ai.chat.model.ChatModel;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import top.kangyaocoding.tech.common.RedisChatMemory;

/**
 * 描述: Chat 聊天配置
 *
 * @author K·Herbert
 * @since 2025-04-13 23:14
 */

@Configuration
public class ChatConfig {
    @Bean
    public ChatClient chatClient(ChatModel ollamaChatModel, RedisChatMemory redisChatMemory) {
        return ChatClient.builder(ollamaChatModel)
                .defaultSystem("你是一个智能助手。首选语言是中文。")
                .defaultAdvisors(new MessageChatMemoryAdvisor(redisChatMemory))
                .build();
    }

}
